package com.example.treasure_back.controller;

import com.example.treasure_back.entity.MsgEntity;
import com.example.treasure_back.model.ThumbModel;
import com.example.treasure_back.service.ThumbService;
import com.example.treasure_back.shiroEntity.auth.AuthUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/treasure/thumb")
public class ThumbController {

    @Autowired
    private ThumbService thumbService;

    @RequestMapping("/getInfoById/{essayId}")
    public MsgEntity getInfoById(@PathVariable Integer essayId,@AuthUser String userId){
        ThumbModel thumbModel = thumbService.getInfoById(essayId, userId);
        return new MsgEntity("SUCCESS","200",thumbModel);
    }

    @RequestMapping("/setLikeById/{essayId}")
    public MsgEntity setLikeById(@PathVariable Integer essayId,@AuthUser String userId){
        return new MsgEntity("SUCCESS","200",thumbService.setLikeById(essayId,userId));
    }

    @RequestMapping("/setDisLikeById/{essayId}")
    public MsgEntity setDisLikeById(@PathVariable Integer essayId,@AuthUser String userId){
        return new MsgEntity("SUCCESS","200",thumbService.setDisLikeById(essayId,userId));
    }
}
